<?php
/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/


$op=$_GET['op'];

?>

<div class='table'>

    <h3 class='bartitle'>Gest Multi-Gallery</h3>

    <p>
<?php
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

if ((defined('LIBGROUP') && group_getusergroup("multigallery",user_getuser())) || admin_isadmin()){

	if($op==""){
?>
<center>
	    <form method="post" action="index.php?appname=<?=$appname;?>&op=crea" method='post'><b><font color="#009900">(Insert Name for New Gallery Creation)</font></b><br>
		<input size="25" type="text" name="newappl"><br />
        </b><input type="submit" value="crea"> <input type="reset" value="resetta">
	    <br>
        </form>
</center>
	    <hr>
<center>
	    <form method="post" action="index.php?appname=<?=$appname;?>&op=elimina" method='post'><font color="#ff0000"><b>(Insert Name of to delete Gallery)</b></font><br>
		<input size="25" type="text" name="delappl"> <br />
        <input type="submit" value="elimina"> <input type="reset" value="resetta">
	    </form>
</center>

<br>
	    <hr>

<?php
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if($op=="delebloccodx"){
    // nuova routine per eliminazione applicazione dentro una altra applicazione //
    if ($_POST['deldentroappl']!="") {
	$deldentroappl=$_POST['deldentroappl']."/";
    }
    $delappl=$_POST['deleblocdx'];

    if (file_exists("blocks/right/$deldentroappl".$delappl)){
	$fd=opendir("blocks/right/$deldentroappl".$delappl);
	while (false !== ($nf= readdir($fd))){
	    if ($nf[0]!='.' && $nf[0]!='_'  )
		unlink("blocks/right/$deldentroappl".$delappl."/$nf");
	}
	closedir($fd);
	rmdir("blocks/right/$deldentroappl/$delappl");
    }

    if (file_exists("datas/blocks/right/$deldentroappl".$delappl)){
	$fd=opendir("datas/blocks/right/$deldentroappl".$delappl);
	while (false !== ($nf= readdir($fd))){
	    if ($nf[0]!='.' && $nf[0]!='_'  )
		unlink("datas/blocks/right/$deldentroappl".$delappl."/$nf");
	}
	closedir($fd);
	rmdir("datas/blocks/right/$deldentroappl/$delappl");
    }

    echo "blocco DX eliminato<br />";
    echo "<p align='right'><a href='index.php?appname=$appname'>continua</a></p>";
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if($op=="crea"){

$applicazione=basename($appname,"/".$subapp);


    $newappl=$_POST['newappl'];
    
    mkdir("applications/$applicazione/".$newappl,0755);
    mkdir("applications/$applicazione/$newappl/lang",0755);
    copy( "applications/$appname/_template/application.inc", "applications/$applicazione/$newappl/application.inc");
    copy( "applications/$appname/_template/lang/de.inc", "applications/$applicazione/$newappl/lang/de.inc");
    copy( "applications/$appname/_template/lang/en.inc", "applications/$applicazione/$newappl/lang/en.inc");
    copy( "applications/$appname/_template/lang/es.inc", "applications/$applicazione/$newappl/lang/es.inc");
    copy( "applications/$appname/_template/lang/it.inc", "applications/$applicazione/$newappl/lang/it.inc");

echo $appname." nome<br>";
echo $apptitle." titolo<br>";
echo $applicazione." applicazione<br>";

    echo "New Gallery Creation ... done !!!<br>";
    echo "<p align='right'><a href='index.php?appname=$appname'>[CONTINUE]</a></p>";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if($op=="elimina"){
    // nuova routine per eliminazione applicazione dentro una altra applicazione //
    $delappl=$_POST['delappl'];
    $applicazione=basename($appname,"/".$subapp);

echo "applications/$applicazione/$delappl<br />";
    deltree("applications/$applicazione/$delappl");
    rmdir("applications/$applicazione/$delappl/lang");
    rmdir("applications/$applicazione/$delappl");

    echo "Gallery eliminata<br />";
    echo "<p align='right'><a href='index.php?appname=$appname'>continua</a></p>";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
?>

    </p>
</div>
